/**
 * 初始化省份选择列表。
 * 
 * @param provinceSelect
 *            省份选择列表
 */
function initProvinceSelect(provinceSelect) {
	provinceList = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
			17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 ];
	provinceList[0] = "全国范围";
	provinceList[1] = "安徽";
	provinceList[2] = "北京";
	provinceList[3] = "福建";
	provinceList[4] = "甘肃";
	provinceList[5] = "广东";
	provinceList[6] = "广西";
	provinceList[7] = "贵州";
	provinceList[8] = "海南";
	provinceList[9] = "河北";
	provinceList[10] = "河南";
	provinceList[11] = "黑龙江";
	provinceList[12] = "湖北";
	provinceList[13] = "湖南";
	provinceList[14] = "吉林";
	provinceList[15] = "江苏";
	provinceList[16] = "江西";
	provinceList[17] = "辽宁";
	provinceList[18] = "内蒙古";
	provinceList[19] = "宁夏";
	provinceList[20] = "青海";
	provinceList[21] = "山东";
	provinceList[22] = "山西";
	provinceList[23] = "陕西";
	provinceList[24] = "上海";
	provinceList[25] = "四川";
	provinceList[26] = "台湾";
	provinceList[27] = "天津";
	provinceList[28] = "西藏";
	provinceList[29] = "新疆";
	provinceList[30] = "云南";
	provinceList[31] = "浙江";
	provinceList[32] = "重庆";
	provinceList[33] = "香港";
	provinceList[34] = "澳门";

	clearAndFillSelect(provinceSelect, provinceList);

	provinceSelect.options[0].value = "";
	provinceSelect.value = provinceList[0];
};

/**
 * 根据指定的省份初始化城市选择列表。
 * 
 * @param selectedProvince 省份名称
 * @param select 城市选择列表
 */
function initCitySelect(selectedProvince, citySelect) {
	clearAndFillSelect(citySelect, getCities(selectedProvince));
	citySelect.selectedIndex = 0;
};

/**
 * 根据指定的省份名称获取该省份内的所有城市的列表。
 * 
 * @param province
 *            省份名称
 * @returns 城市列表
 */
function getCities(province) {
	if("" == province) {
		return "";
	} else {
		if(province == "安徽") return Array("请选择城市...","安庆","蚌埠","亳州","巢湖","池州","滁州","阜阳","合肥","淮北","淮南","黄山","六安","马鞍山","宿州","铜陵","芜湖","宣城");
		if(province == "澳门") return Array("请选择城市...","澳门");
		if(province == "北京") return Array("请选择城市...","北京");
		if(province == "重庆") return Array("请选择城市...","重庆");
		if(province == "福建") return Array("请选择城市...","福州","龙岩","南平","宁德","莆田","泉州","三明","厦门","漳州");
		if(province == "甘肃") return Array("请选择城市...","白银","定西","甘南","藏族自治州","嘉峪关","金昌","酒泉","兰州","临夏回族自治州","陇南","平凉","庆阳","天水","武威","张掖");
		if(province == "广东") return Array("请选择城市...","潮州","东莞","佛山","广州","河源","惠州","江门","揭阳","茂名","梅州","清远","汕头","汕尾","韶关","深圳","阳江","云浮","湛江","肇庆","中山","珠海");
		if(province == "广西") return Array("请选择城市...","百色","北海","崇左","防城港","贵港","桂林","河池","贺州","来宾","柳州","南宁","钦州","梧州","玉林");
		if(province == "贵州") return Array("请选择城市...","安顺","毕节","贵阳","六盘水","黔东南苗族侗族自治州","黔南布依族苗族自治州","黔西南布依族苗族自治州","铜仁","遵义");
		if(province == "海南") return Array("请选择城市...","白沙黎族自治县","保亭黎族苗族自治县","昌江黎族自治县","澄迈县","儋州","定安县","东方","海口","乐东黎族自治县","临高县","陵水黎族自治县","琼海","琼中黎族苗族自治县","三亚","屯昌县","万宁","文昌","五指山");
		if(province == "河北") return Array("请选择城市...","保定","沧州","承德","邯郸","衡水","廊坊","秦皇岛","石家庄","唐山","邢台","张家口");
		if(province == "河南") return Array("请选择城市...","安阳","鹤壁","济源","焦作","开封","洛阳","漯河","南阳","平顶山","濮阳","三门峡","商丘","新乡","信阳","许昌","郑州","周口","驻马店");
		if(province == "黑龙江") return Array("请选择城市...","大庆","大兴安岭","哈尔滨","鹤岗","黑河","鸡西","佳木斯","牡丹江","七台河","齐齐哈尔","双鸭山","绥化","伊春");
		if(province == "湖北") return Array("请选择城市...","鄂州","恩施","黄冈","黄石","荆门","荆州","潜江","神农架林区","十堰","随州","天门","武汉","仙桃","咸宁","襄樊","孝感","宜昌");
		if(province == "湖南") return Array("请选择城市...","长沙","常德","郴州","衡阳","怀化","娄底","邵阳","湘潭","湘西","土家族苗族自治州","益阳","永州","岳阳","张家界","株洲");
		if(province == "吉林") return Array("请选择城市...","白城","白山","长春","吉林","辽源","四平","松原","通化","延边朝鲜族自治州");
		if(province == "江苏") return Array("请选择城市...","常熟","常州","淮安","江阴","靖江","昆山","连云港","南京","南通","苏州","宿迁","泰州","无锡","徐州","盐城","扬州","张家港","镇江");
		if(province == "江西") return Array("请选择城市...","抚州","赣州","吉安","景德镇","九江","南昌","萍乡","上饶","新余","宜春","鹰潭");
		if(province == "辽宁") return Array("请选择城市...","鞍山","本溪","朝阳","大连","丹东","抚顺","阜新","葫芦岛","锦州","辽阳","盘锦","沈阳","铁岭","营口");
		if(province == "内蒙古") return Array("请选择城市...","阿拉善盟","彦淖尔盟","包头","赤峰","鄂尔多斯","呼和浩特","呼伦贝尔","通辽","乌海","乌兰察布盟","锡林郭勒盟","兴安盟");
		if(province == "宁夏") return Array("请选择城市...","固原","石嘴山","吴忠","银川","中卫市");
		if(province == "青海") return Array("请选择城市...","果洛藏族自治州","海北藏族自治州","海东","海南藏族自治州","海西蒙古族藏族自治州","黄南藏族自治州","西宁","玉树藏族自治州");
		if(province == "山东") return Array("请选择城市...","滨州","德州","东营","荷泽","菏泽","济南","济宁","莱芜","聊城","临沂","青岛","日照","泰安","威海","潍坊","烟台","枣庄","淄博");
		if(province == "山西") return Array("请选择城市...","长治","大同","晋城","晋中","临汾","吕梁","朔州","太原","忻州","阳泉","运城");
		if(province == "陕西") return Array("请选择城市...","安康","宝鸡","汉中","商洛","铜川","渭南","西安","咸阳","延安","榆林");
		if(province == "上海") return Array("请选择城市...","上海");
		if(province == "四川") return Array("请选择城市...","阿坝藏族羌族自治州","巴中","成都","达州","德阳","甘孜藏族自治州","广安","广元","乐山","凉山彝族自治州","泸州","眉山","绵阳","内江","南充","攀枝花","遂宁","雅安","宜宾","资阳","自贡");
		if(province == "台湾") return Array("请选择城市...","高雄","台北");
		if(province == "天津") return Array("请选择城市...","天津");
		if(province == "西藏") return Array("请选择城市...","阿里","昌都","拉萨","林芝","那曲","日喀则","山南");
		if(province == "香港") return Array("请选择城市...","香港");
		if(province == "新疆") return Array("请选择城市...","阿克苏","阿拉尔","巴音郭楞蒙古自治州","博尔塔拉蒙古自治州","昌吉回族自治州","哈密","和田","喀什","克拉玛依","克孜勒苏柯尔克孜自治州","石河子","图木舒克","吐鲁番","乌鲁木齐","五家渠","伊犁");
		if(province == "云南") return Array("请选择城市...","保山","楚雄彝族自治州","大理","德宏傣族景颇族自治州","迪庆","红河哈尼族彝族自治州","昆明","丽江","临沧","怒江傈傈族自治州","曲靖","思茅","文山壮族苗族自治州","西双版纳","玉溪","昭通");
		if(province == "浙江") return Array("请选择城市...","杭州","湖州","嘉兴","金华","丽水","宁波","衢州","绍兴","台州","温州","舟山");
		//if(province == "安徽") return Array("请选择省份...","安徽,澳门,北京,重庆,福建,甘肃,广东,广西,贵州,海南,河北,河南,黑龙江,湖北,湖南,吉林,江苏,江西,辽宁,内蒙古,宁夏,青海,山东,山西,陕西,上海,四川,台湾,天津,西藏,香港,新疆,云南,浙江");
		return Array("请选择城市...");
	}
}

/**
 * 清空列表并为列表填充指定的值数组。
 * 
 * @param select
 *            列表
 * @param opts
 *            要填充的值数组
 */
function clearAndFillSelect(select, opts) {
	clearSelect(select);
	fillSelect(select, opts);
}

/**
 * 清空指定的列表。
 * 
 * @param select
 *            列表
 */
function clearSelect(select) {
	var opts = select.options;

	while (opts.length > 0) {
		select.removeChild(opts[0]);
	}
};

/**
 * 为列表填充指定的值数组。
 * 
 * @param select
 *            列表
 * @param opts
 *            要填充的值数组
 */
function fillSelect(select, opts) {
	for ( var i = 0; i < opts.length; i++) {
		select.add(new Option(opts[i], opts[i]));
	}
}